package com.keyidea.jfxui.core.server.listener;

import com.keyidea.jfxui.core.server.job.DynamicMessagePrintJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * UDP系统启动时执行初始化任务
 */
@Lazy
@Slf4j
@Component
@RequiredArgsConstructor
public class InitListener implements ApplicationListener<ContextRefreshedEvent> {

    private final DynamicMessagePrintJob dynamicMessagePrintJob;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (null == event.getApplicationContext().getParent()) {
            // 动态输出消息
            //dynamicMessagePrintJob.startUp();
        }
    }

    @Override
    public boolean supportsAsyncExecution() {
        return ApplicationListener.super.supportsAsyncExecution();
    }
}
